<?php
/**
 * 文件管理-店铺文件（已停用）
 * (model)
 */
namespace App\Models\File;

use App\Models\Basics\AmazonArea;
use App\Models\Basics\SysCountry;
use Illuminate\Database\Eloquent\Model;
class FileStore extends Model
{
    protected $table = 'file_store';

    protected $guarded = [];

    public static $_fileType = [
        1 => 'Payment',
        2 => 'FBAInventory',
        3 => 'HealthInventory',
        5 => 'MonthlyStorage',
        6 => 'LongTermStorage',
        9 => 'AdsMonthly',
        12 => 'MVideoCampaign',
        13 => 'MBrandsCampaign',
    ];

    public static $_fileTypeForArea = [
        2 => 'FBAInventory',
        3 => 'HealthInventory',
        5 => 'MonthlyStorage',
        6 => 'LongTermStorage',
    ];

    public static $_fileTypeForCountry = [
        1 => 'Payment',
        2 => 'FBAInventory',
        9 => 'AdsMonthly',
        12 => 'MVideoCampaign',
        13 => 'MBrandsCampaign',
    ];

    public static $_status = [
        1 => '未解析',
        2 => '已解析',
    ];

    public function country()
    {
        return $this->belongsTo(SysCountry::class,'country_id');
    }

    public function area()
    {
        return $this->belongsTo(AmazonArea::class,'area_id');
    }

    public static function fileDir($time){
        return 'store'.DIRECTORY_SEPARATOR.date('Ym',$time);
    }

    public static function fileName($areaId,$countryId,$fileType,$userId,$fileName){
        return $areaId.'-'.$countryId.'-'.$fileType.'-'.$userId.'-'.$fileName;
    }
}
